<template>
	
	<form @submit="submit" :data-action="`/api/quipment/save?stationId=${param.id}`">
			
			<view class="father">
				<view class="fixAuto bb middle ">
					<view class="w100">
						设备监测因子
					</view>
					<view class="text-right">
						{{factorList[factorIndex]}}
						<text class="ml5 sIcon-arrowRight grey"></text>
					</view>
				</view>
				<picker class="op0 abs" mode="selector" :range="factorList" :value="factorIndex" @change="changeFactor">
					<view class="op0 abs">{{factor}}</view>
				</picker>
			</view>
			
			<view  :class="{none : !isOtherFator}">
				<view class="fixAuto bb middle">
					<view class="w100">
						其他监测因子
					</view>
					<view>
						<input type="text" name="x.factor|设备监测因子|0~200" v-model="factor" placeholder="请输入设备监测因子">
					</view>
				</view>
			</view>
			
			<view class="fixAuto bb middle">
				<view class="w100">
					设备名称
				</view>
				<view>
					<input type="text" name="x.name|设备名称|0~200" placeholder="请输入设备名称">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					设备型号
				</view>
				<view>
					<input type="text" name="x.model|设备型号|0~200" placeholder="请输入设备型号">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					生产商
				</view>
				<view>
					<input type="text" name="x.manufacture|生产商|0~200" placeholder="请输入生产商">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					设备出厂编号
				</view>
				<view>
					<input type="text" name="x.factoryNum|设备出厂编号|0~200" placeholder="请输入设备出厂编号">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					环保认证编号
				</view>
				<view>
					<input type="text" name="x.certificationNo|环保产品认证编号|0~200" placeholder="请输入环保产品认证编号">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					测试方法
				</view>
				<view>
					<input type="text" name="x.testMethod|测试方法|0~200" placeholder="请输入测试方法">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					检出限
				</view>
				<view>
					<input type="text" name="x.detectionLimit|检出限|0~200" placeholder="请输入检出限">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					分析周期
				</view>
				<view>
					<input type="text" name="x.analysisCycle|分析周期|0~200" placeholder="请输入分析周期">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					量程F.S.
				</view>
				<view>
					<input type="text" name="x.range|量程F.S.|0~200" placeholder="请输入量程F.S.">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					标准曲线参数
				</view>
				<view>
					<input type="text" name="x.standardCurve|标准曲线参数|0~200" placeholder="请输入标准曲线参数">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					仪器流量范围
				</view>
				<view>
					<input type="text" name="x.flowRange|仪器流量范围|0~200" placeholder="请输入仪器流量范围">
				</view>
			</view>
			<view class="fixAuto bb ">
				<view class="w100">
					验收时间
				</view>
				<view class="father">
					<view class="flex " :class="acceptanceTime?'':'rt'">
						<view :class="acceptanceTime?'black':'gray'">
							{{acceptanceTime?acceptanceTime:'请选择'}}
							<input type="text" name="x.acceptanceTime|验收时间" v-model="acceptanceTime" style="display: none;">
						</view>
						<view class="sIcon-arrowRight fz14 grey pl10"></view>
					</view>
					<view class="abs op0">
						<picker mode="date" @change="acceptanceTime = $event.detail.value">
							<view>验收时间</view>
						</picker>
					</view>
				</view>
			</view>
			
			<view class="fixAuto bb middle">
				<view class="w100">
					验收监测单位
				</view>
				<view>
					<input type="text" name="x.acceptanceCompany|验收监测单位|0~200" placeholder="请输入验收监测单位">
				</view>
			</view>
			<view class="fixAuto bb ">
				<view class="w100">
					联网时间
				</view>
				<view class="father">
					<view class="flex " :class="networkingTime?'':'rt'">
						<view :class="networkingTime?'black':'gray'">
							{{networkingTime?networkingTime:'请选择'}}
							<input type="text" name="x.networkingTime|联网时间" v-model="networkingTime" style="display: none;">
						</view>
						<view class="sIcon-arrowRight fz14 grey pl10"></view>
					</view>
					<view class="abs op0">
						<picker mode="date" @change="networkingTime = $event.detail.value">
							<view>联网时间</view>
						</picker>
					</view>
				</view>
			</view>
			
			
			<view class="plr100 pd30">
				<button form-type="submit" class="btn gradualBg shadow block rds23">
					保存
				</button>
			</view>
		</form>

	</layout>
</template>

<script>
	export default {
		data() {
			return {
				factorList:[],
				factorIndex:0,
				param:{id:""} ,
				factor:"",
				acceptanceTime:"",
				networkingTime:""
			}
		},
		onLoad(params) {
			this.param = params ;
			this.getOptions();
		},
		computed:{
			isOtherFator : function(e){
				return this.factorList[this.factorIndex] == '其他' ;
			}
		},
		methods: {
			getOptions : function(e){
				var data = {
					stationId : this.param.id 
				} ;
				this.kit.get("/api/quipment/options",data,res => {
					res.list.push("其他");
					this.factor = res.list.length > 1 ? res.list[0] : "" ;
					this.factorList = res.list ;
				});
			},
			changeFactor:function(e){
				this.factorIndex = e.detail.value ;
				var factor = this.factorList[this.factorIndex] ;
				this.factor = factor == '其他' ? '' : factor ;
			},
			submit:function(e){
				this.form.submit(e , this.success);
			},
			
			success:function(e){
				this.kit.goSuccessBack("保存成功");
			}
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>